<template>
  <div class="loading-container" :class="{ 'loading-fullscreen': fullscreen }">
    <div class="loading-content">
      <el-icon class="loading-icon" :size="size">
        <Loading />
      </el-icon>
      <div v-if="text" class="loading-text">{{ text }}</div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ElIcon } from 'element-plus';
import { Loading } from '@element-plus/icons-vue';

interface Props {
  text?: string;
  size?: number;
  fullscreen?: boolean;
}

withDefaults(defineProps<Props>(), {
  size: 40,
  fullscreen: false
});
</script>

<style scoped lang="scss">
.loading-container {
  display: flex;
  justify-content: center;
  align-items: center;
  
  &.loading-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    z-index: 1000;
  }
  
  .loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    
    .loading-icon {
      animation: rotate 2s linear infinite;
    }
    
    .loading-text {
      font-size: 14px;
      color: var(--el-text-color-secondary);
    }
  }
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
</style>